import {createData} from "../util/addData.js";
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();

export const addKeyword = async (data) => {
    return await createData(data, 'Keyword')
}

export const queryKeyword = async (name) => {
    return await prisma.Keyword.findFirst({
        where: {
            name: name,
        },
    });
}
export const queryKeywordAll = async () => {
    return await prisma.Keyword.findMany();
}

export const deleteKeyword = async (id) => {
   try{
       const res =  await prisma.Keyword.delete({
           where: {
               id: Number(id),
           },
       });
       return res
   }catch (e) {
       console.log(e.message)
   }
}
